/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.news;

import LangTools.LangIdentifyTool;
import cn.ac.iie.di.ban.ycl.idgen.IDGeneratorInterface;
import cn.ac.iie.di.ban.ycl.idgen.IDSHAGeneratorImpl;
import cn.ac.iie.di.global.GlobalParas;
import static cn.ac.iie.di.global.GlobalParas.FILE_PATH;
import cn.ac.iie.di.rocketmq.Message;
import cn.ac.iie.di.tools.Base64;
import cn.ac.iie.di.tools.GenerateMD5;
import cn.ac.iie.di.tools.GetIpTools;
import cn.ac.iie.di.tools.RemoveDuplicate;
import cn.ac.iie.di.tools.SHA;
//import cn.ac.iie.di.tools.LongHashCode;
//import cn.ac.iie.di.tools.MMUrlPath;
import cn.ac.iie.di.tools.SplitJsonArray;
import cn.ac.iie.di.tools.TimeFormat;
//import cn.ac.iie.di.tools.TimeTransfer;
import java.io.File;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import cn.ac.iie.di.tools.SwitchProvince;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.logging.Level;
import net.sf.json.JSONObject;
import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;

/**
 *
 * @author lenovo-pc
 */
public class JsonNewsTask implements Runnable {

    private final List<Message> jsonList;

    private HashMap<String, String> JsonData = new HashMap<>();//存储Json中的数据1
    static private final Logger logger = Logger.getLogger(JsonNewsTask.class.getName());
    static private final AtomicInteger count = new AtomicInteger(0);

//    TrsCkmSoapClient client = new TrsCkmSoapClient();
    public static void printLog(int n) {
        if (count.addAndGet(n) > 500) {
            boolean print = false;
            int cur = 0;
            synchronized (count) {
                cur = count.get();
                if (cur > 500) {
                    count.addAndGet(-cur);
                    print = true;
                }
            }
            if (print) {
                logger.info("The fans parser " + cur);
            }
        }
    }

    public JsonNewsTask(List<Message> jsonList) {
        this.jsonList = jsonList;
    }

    @Override
    public void run() {
//        client.SetServer(GlobalParas.IP_TRS, "admin", "trsadmin");
        IDGeneratorInterface iDGeneratorInterface = new IDSHAGeneratorImpl();

        long line = 0;
        try {
            for (Message json : jsonList) {
                if (json != null && json.getData().size() != 0) {
                    List<Object[]> dataList = json.getData();
                    String[] colNames = json.getColNames();
                    logger.debug("colNames are "+JSONArray.fromArray(colNames).toString());
                    logger.debug("colTypes are "+JSONArray.fromArray(json.getTypes()).toString());
                    Map<String, Integer> nameIndex = new HashMap<>();
                    for (int id = 0; id < colNames.length; id++) {
                        nameIndex.put(colNames[id], id);
                    }
   
                    for (int i = 0; i < dataList.size(); i++) {
                        try {
                            Object[] dataArr = dataList.get(i);
                            logger.debug("colValues are "+JSONArray.fromArray(dataArr).toString());
                            String type = (String) dataArr[nameIndex.get("msg_type")];
                            Map<String, Object> map = null;
//                            logger.info("MT is : "+type);
                            switch (type) {
                                case "1":
//                                    logger.info(Arrays.toString(dataArr));
//                                    logger.info(nameIndex);
                                    map = newsParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.NEWS1_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.NEWS1_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "2":
                                    map = commentParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.COMMENT1_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.COMMENT1_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "3":
                                    map = newsParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.NEWS2_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.NEWS2_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "4":
                                    map = commentParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.COMMENT2_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.COMMENT2_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "5":
                                    map = userParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.USER_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.USER_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "appstore.basicinfo":
                                    map = appStoreParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.APP_STORE_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.APP_STORE_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "appstore.appcategory":
                                    map = appCategoryParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.APP_CATEGORY_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.APP_CATEGORY_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "appstore.app":
                                    map = appInfoParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.APP_INFO_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.APP_INFO_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "appstore.appcomments":
                                    map = appCommentParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.APP_COMMENT_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.APP_COMMENT_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                case "appstore.appcompany":
                                    map = appDeveloperParser(dataArr, nameIndex);
                                    if (null == map || map.size() == 0) {
                                        logger.error("parser error dataArr is : " + Arrays.toString(dataArr) + " nameIndex: " + nameIndex);
                                        continue;
                                    }
                                    while (!GlobalParas.APP_DEVELOPER_QUEUE.offer(map)) {
                                        logger.info("GlobalParas.APP_DEVELOPER_QUEUE is full!");
                                        Thread.sleep(3000);
                                    }
                                    break;
                                        
                                default:
                                    logger.warn("unknow type: " + type + " content: " + Arrays.toString(dataArr));
                            }
                        } catch (Exception e) {
                            logger.error("The session add is wrong:" + e.getMessage(), e);
                        }
                    }
                }
            }
//            logger.info("FANS successful send " + line);
            line = 0;
        } catch (Exception ex) {
            logger.error("know fans Task error " + ex, ex);
        }
    }

    /**
     * 按tp_msg_news 方式解析
     *
     * @param dataArr 数据包
     * @param nameIndex 字段位置对应关系
     * @return
     */
    public static Map<String, Object> newsParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        String type = (String) dataArr[nameIndex.get("msg_type")];
        if ("3".equals(type)) {
            try {
                msgMap.put("m_url_domain", (String) dataArr[nameIndex.get("DOMAIN")]);
                msgMap.put("g_channel", (String) dataArr[nameIndex.get("CHANNEL")]);
                String url = new String(Base64.decodeFast((String) dataArr[nameIndex.get("ORIGINURL")]), "utf-8");
                msgMap.put("g_ch_key", url);
                String m_pv_cnt = ((dataArr[nameIndex.get("PVNUM")]).toString());
                if (null != m_pv_cnt && !m_pv_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_pv_cnt)) {
                    try {
                        msgMap.put("m_pv_cnt", Long.valueOf(m_pv_cnt));//PVNUM
                    } catch (Exception e) {
                        logger.error("m_pv_cnt is : " + m_pv_cnt + e, e);
                    }
                } else {
                    msgMap.put("m_pv_cnt", -1);
                }
                String m_uv_cnt = (dataArr[nameIndex.get("UVNUM")]).toString();
                if (null != m_uv_cnt && !m_uv_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_uv_cnt)) {
                    try {
                        msgMap.put("m_uv_cnt", Long.valueOf(m_uv_cnt));//UVNUM
                    } catch (Exception e) {
                        logger.error("m_uv_cnt is : " + m_pv_cnt + e, e);
                    }
                } else {
                    msgMap.put("m_uv_cnt", -1);
                }
                if (null != dataArr[nameIndex.get("JOINNUM")]) {
                    String m_join_cnt = (dataArr[nameIndex.get("JOINNUM")]).toString();
                    if (null != m_join_cnt && !m_join_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_join_cnt)) {
                        try {
                            msgMap.put("m_join_cnt", Long.valueOf(m_join_cnt));//JOINNUM
                        } catch (Exception e) {
                            logger.error("m_join_cnt is : " + m_pv_cnt + e, e);
                        }
                    } else {
                        msgMap.put("m_join_cnt", -1);
                    }
                } else {
                    msgMap.put("m_join_cnt", -1);
                }

                if (null != dataArr[nameIndex.get("SHARENUM")]) {
                    String m_forward_cnt = (dataArr[nameIndex.get("SHARENUM")]).toString();
                    if (null != m_forward_cnt && !m_forward_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_forward_cnt)) {
                        try {
                            msgMap.put("m_forward_cnt", Long.valueOf(m_forward_cnt));//SHARENUM
                        } catch (Exception e) {
                            logger.error("m_forward_cnt is : " + m_pv_cnt + e, e);
                        }
                    } else {
                        msgMap.put("m_forward_cnt", -1);
                    }
                } else {
                    msgMap.put("m_forward_cnt", -1);
                }
                if (null != dataArr[nameIndex.get("REPLYNUM")]) {
                    String m_reply_cnt = (dataArr[nameIndex.get("REPLYNUM")]).toString();
                    if (null != m_reply_cnt && !m_reply_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_reply_cnt)) {
                        try {
                            msgMap.put("m_reply_cnt", Long.valueOf(m_reply_cnt));//REPLYNUM
                        } catch (Exception e) {
                            logger.error("m_reply_cnt is : " + m_pv_cnt + e, e);
                        }
                    } else {
                        msgMap.put("m_reply_cnt", -1);
                    }
                } else {
                    msgMap.put("m_reply_cnt", -1);
                }
                msgMap.put("m_url_domain", (String) dataArr[nameIndex.get("DOMAIN")]);        
                msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
                
            String gt = "";
            if (null != nameIndex.get("gt")) {//判断有没有该字段,字符串为""不代表为null
                if (null!=(String)(dataArr[nameIndex.get("gt")]) && "null"!= ((String)dataArr[nameIndex.get("gt")]) && ""!= ((String)dataArr[nameIndex.get("gt")]).trim()) {//判断该字段有没有值
                    gt = (String) dataArr[nameIndex.get("gt")];
                    msgMap.put("m_gather_time", gt);
                } else {
                    msgMap.put("m_gather_time", -1);
                    logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
                }
            } else {
                msgMap.put("m_gather_time", -1);
                logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
            }  
           
            if (null != nameIndex.get("key")) {
                String key = ((dataArr[nameIndex.get("key")]).toString());
                if (null != key && !key.trim().isEmpty() && !"null".equalsIgnoreCase(key)) {
                    msgMap.put("key", key);
                }else {
                    msgMap.put("key", "");
                }
            } else {
                logger.error("key doesn't exist");
                msgMap.put("key", "");
            }
                return msgMap;
            } catch (Exception e) {
                logger.error(e, e);
                return null;
            }
        }
        try {
            msgMap.put("m_url_domain", (String) dataArr[nameIndex.get("DOMAIN")]);
            msgMap.put("g_channel", (String) dataArr[nameIndex.get("CHANNEL")]);
            String url = new String(Base64.decodeFast((String) dataArr[nameIndex.get("ORIGINURL")]), "utf-8");
            msgMap.put("g_ch_key", url);
            msgMap.put("m_url", url);
            
            String u_name = null;
            if (null != nameIndex.get("AUTHOR")) {
                u_name = (String) dataArr[nameIndex.get("AUTHOR")]; 
                if (null != u_name && !u_name.trim().isEmpty() && !"null".equals(u_name)) {
                    u_name = new String(Base64.decodeFast((String) dataArr[nameIndex.get("AUTHOR")]), "utf-8");//AUTHOR
                     msgMap.put("u_name", u_name);
                } else {
                     msgMap.put("u_name", "null"); 
                }
            } else {
                msgMap.put("u_name", "null");
            }   
            
            String title = new String(Base64.decodeFast((String) dataArr[nameIndex.get("TITLE")]), "utf-8");//TITLE
            msgMap.put("m_title", title);
            String content = "";
            if (null != nameIndex.get("TEXT")) {
                if (null != (String) dataArr[nameIndex.get("TEXT")]) {
                    content = new String(Base64.decodeFast((String) dataArr[nameIndex.get("TEXT")]), "utf-8");//TEXT
                     msgMap.put("m_content", content); 
                } else {
                     msgMap.put("m_content", ""); 
                }
            } else {
                msgMap.put("m_content", "");
            }   
            String publishTime = (String) dataArr[nameIndex.get("PUBLISHTIME")];//PUBLISHTIME
            try {
                if (null == publishTime || publishTime.trim().isEmpty()) {
                    msgMap.put("m_is_pt_generated", 1);
                } else {
                    msgMap.put("m_is_pt_generated", 0);
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_is_pt_generated", 0);
                msgMap.put("m_publish_time", -1);
            }
            
            String gt = "";
            if (null != nameIndex.get("gt")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("gt")] && "null"!= ((String)dataArr[nameIndex.get("gt")]) && ""!= ((String)dataArr[nameIndex.get("gt")]).trim()) {//判断该字段有没有值
                    gt = (String) dataArr[nameIndex.get("gt")];
                    msgMap.put("m_gather_time", gt);
                } else {
                    msgMap.put("m_gather_time", -1);
                    logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
                }
            } else {
                msgMap.put("m_gather_time", -1);
                logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
            }  
            
            if (null != nameIndex.get("DOWNTIME")) {
                if (null != (String) dataArr[nameIndex.get("DOWNTIME")] && !((String) dataArr[nameIndex.get("DOWNTIME")]).trim().isEmpty()) {
                    msgMap.put("m_down_time", TimeFormat.dateToStamp((String) dataArr[nameIndex.get("DOWNTIME")]));
                } else {
                    msgMap.put("m_down_time", "null");
                }
            }else {
                msgMap.put("m_down_time", "null");
            }    

            String[] specialUrls={};
            if (null != nameIndex.get("SPECIALURL")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("SPECIALURL")] && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("SPECIALURL")]) && !((String)dataArr[nameIndex.get("SPECIALURL")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("SPECIALURL")])) {//判断该字段有没有值
                    specialUrls = baseUrlsToUrls((String) dataArr[nameIndex.get("SPECIALURL")]);
                    msgMap.put("m_special_urls",specialUrls);
                } else {
                    msgMap.put("m_special_urls", new String[0]);
                }
            } else {
                msgMap.put("m_special_urls", new String[0]);
            }      
            
            String[] picUrls={};
            if (null != nameIndex.get("PHOTOURLS")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("PHOTOURLS")] && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("PHOTOURLS")]) && !((String)dataArr[nameIndex.get("PHOTOURLS")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("PHOTOURLS")])) {//判断该字段有没有值
//                    logger.info("kkkkk" + (String) dataArr[nameIndex.get("PHOTOURLS")]);
                    picUrls = baseUrlsToUrls((String) dataArr[nameIndex.get("PHOTOURLS")]);
                    msgMap.put("ma_picture_urls",picUrls);
//                    logger.info("zzzzzz" + picUrls);
                } else {
                    msgMap.put("ma_picture_urls", new String[0]);
                }

            } else {
                msgMap.put("ma_picture_urls", new String[0]);
            }      
            String[] audioUrls={};
            if (null != nameIndex.get("AUDIOURLS")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("AUDIOURLS")] && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("AUDIOURLS")]) && !((String)dataArr[nameIndex.get("AUDIOURLS")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("AUDIOURLS")])) {//判断该字段有没有值
                    audioUrls = baseUrlsToUrls((String) dataArr[nameIndex.get("AUDIOURLS")]);
                    msgMap.put("ma_audio_urls",audioUrls);
                } else {
                    msgMap.put("ma_audio_urls", new String[0]);
                }
            } else {
                msgMap.put("ma_audio_urls", new String[0]);
            }      
            String[] videoUrls={};
            if (null != nameIndex.get("VIDEOURLS")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("VIDEOURLS")] && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("VIDEOURLS")]) && !((String)dataArr[nameIndex.get("VIDEOURLS")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("VIDEOURLS")])) {//判断该字段有没有值
                    videoUrls = baseUrlsToUrls((String) dataArr[nameIndex.get("VIDEOURLS")]);
                    msgMap.put("ma_video_urls",videoUrls);
                } else {
                    msgMap.put("ma_video_urls", new String[0]);
                }

            } else {
                msgMap.put("ma_video_urls", new String[0]);
            }         
            String[] otherUrls={};
            if (null != nameIndex.get("FILEURLS")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("FILEURLS")] && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("FILEURLS")]) && !((String)dataArr[nameIndex.get("FILEURLS")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("FILEURLS")])) {//判断该字段有没有值
                    otherUrls = baseUrlsToUrls((String) dataArr[nameIndex.get("FILEURLS")]);
                    msgMap.put("ma_other_urls",otherUrls);
                } else {
                    msgMap.put("ma_other_urls", new String[0]);
                }

            } else {
                msgMap.put("ma_other_urls", new String[0]);
            }
            
//            logger.info("jjjjjjjjjj "+dataArr[nameIndex.get("COLUMN")]);
            try{
                msgMap.put("m_board_category", JSONArray.fromObject(dataArr[nameIndex.get("COLUMN")]).toArray(new String[JSONArray.fromObject(dataArr[nameIndex.get("COLUMN")]).size()]));//COLUMN
            }catch(JSONException e){
                msgMap.put("m_board_category", new String[0]);//COLUMN
//                logger.info("xxxxxx "+dataArr[nameIndex.get("COLUMN")]);
            }
            if (null != nameIndex.get("SOURCE")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("SOURCE")] && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("SOURCE")]) && !((String)dataArr[nameIndex.get("SOURCE")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("SOURCE")])) {//判断该字段有没有值
                    msgMap.put("m_source",(String) dataArr[nameIndex.get("SOURCE")]);
                } else {
                    msgMap.put("m_source", "null");
                }

            } else {
                msgMap.put("m_source", "null");
            }
           
            if (null != nameIndex.get("SPECIALNAME")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("SPECIALNAME")] && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("SPECIALNAME")]) && !((String)dataArr[nameIndex.get("SPECIALNAME")]).trim().isEmpty() &&  !"[]".equals((String)dataArr[nameIndex.get("SPECIALNAME")])) {//判断该字段有没有值
                    msgMap.put("m_special_names",baseUrlsToUrls((String) dataArr[nameIndex.get("SPECIALNAME")]));
                } else {
                    msgMap.put("m_special_names", new String[0]);
                }
            } else {
                msgMap.put("m_special_names", new String[0]);
            }   
            
            String mo_status = null;
            if (null != nameIndex.get("STATE")) {
                mo_status = (String) dataArr[nameIndex.get("STATE")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_status", Long.valueOf((String) dataArr[nameIndex.get("STATE")]));//ISDEL
                } else {
                    msgMap.put("mo_status", "null");
                }
            }else {
                msgMap.put("mo_status", "null");
            }   
            String mo_time = null;
            try {
                mo_time = (String) dataArr[nameIndex.get("DELTIME")];
                if (null != mo_time && !mo_time.trim().isEmpty()) {
                    msgMap.put("mo_time", Long.valueOf((String) dataArr[nameIndex.get("DELTIME")]));//DELTIME
                } else {
                    msgMap.put("mo_time", "null");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_time is :" + mo_time + e, e);
                msgMap.put("mo_time", "null");//ISDEL
            }
            
            msgMap.put("m_insert_time", -1);
            msgMap.put("m_update_time", -1);
            msgMap.put("u_g_ch_key", "");
            msgMap.put("g_asp", (String) dataArr[nameIndex.get("DOMAIN")]);
            msgMap.put("m_site_location", 0);
            if (null != publishTime && !publishTime.trim().isEmpty()) {
                try {
                    Map<String, Integer> ymdh = TimeFormat.getYMDH(TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_year", ymdh.get("year"));
                    msgMap.put("m_month", ymdh.get("month"));
                    msgMap.put("m_day", ymdh.get("day"));
                    msgMap.put("m_hour", ymdh.get("hour"));
                } catch (Exception e) {
                    logger.error("publishTime is: " + publishTime + e, e);
                    msgMap.put("m_year", -1);
                    msgMap.put("m_month", -1);
                    msgMap.put("m_day", -1);
                    msgMap.put("m_hour", -1);
                }
            }

            msgMap.put("m_content_len", content.length());
            msgMap.put("m_title_len", title.length());
            msgMap.put("m_cont_sim_tag", GenerateMD5.string2MD5(content));
            msgMap.put("m_cont_sim_rank", RemoveDuplicate.getQCId(GenerateMD5.string2MD5(content))[0]);
            msgMap.put("m_title_sim_tag", GenerateMD5.string2MD5(title));
            msgMap.put("m_title_sim_rank", RemoveDuplicate.getQCId(GenerateMD5.string2MD5(title))[0]);
            msgMap.put("m_url_md5", GenerateMD5.string2MD5(url));
//            logger.info("跑进1.1");
            msgMap.put("m_keywords", GlobalParas.TRS_TOOLS.getMKeyWordList(content));
//            logger.info("跑进1.2");
            HashMap<String, String[]> mxx = GlobalParas.TRS_TOOLS.getMXX(content);
            msgMap.put("m_regions", mxx.get("region"));
            msgMap.put("m_countries", mxx.get("country"));//省份
            msgMap.put("m_provinces", mxx.get("province"));//国家
            msgMap.put("m_organizations", mxx.get("organization"));
            msgMap.put("m_persons", mxx.get("person"));
  
                    
                    
//            logger.info("跑进1.3");
            HashMap[] keyVector = GlobalParas.TRS_TOOLS.getMKeyWordVector(url);
            msgMap.put("m_keyword_vector", Arrays.toString(keyVector));
//            logger.info("跑进1.4");
            HashMap<String, HashMap[]> mxxv = GlobalParas.TRS_TOOLS.getMXXVector(content);
            msgMap.put("m_region_vector", Arrays.toString(mxxv.get("region")));
            msgMap.put("m_country_vector", Arrays.toString(mxxv.get("countries")));//省份
            msgMap.put("m_province_vector", Arrays.toString(mxxv.get("provinces")));//国家
            msgMap.put("m_organization_vector", Arrays.toString(mxxv.get("organization")));
            msgMap.put("m_person_vector", Arrays.toString(mxxv.get("person")));
            msgMap.put("ma_picture_cnt", picUrls.length);
            msgMap.put("ma_picture_files", getFilePath(picUrls, publishTime, "jpg", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")]));
            msgMap.put("ma_pic_ocr_contents", new String[0]);
            msgMap.put("ma_video_cnt", videoUrls.length);
            msgMap.put("ma_video_files", getFilePath(videoUrls, publishTime, "mp4", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")]));
            msgMap.put("ma_audio_cnt", audioUrls.length);
            msgMap.put("ma_audio_files", getFilePath(audioUrls, publishTime, "mp3", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")]));
            msgMap.put("ma_other_cnt", otherUrls.length);
            msgMap.put("ma_other_files", getFilePath(otherUrls, publishTime, "other", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")]));
            msgMap.put("g_extract_version", 0);
            String langType = "";
            try {
                LangIdentifyTool langtool = new LangIdentifyTool();
                langtool.initText(content);
                langType = langtool.getLangType();
                msgMap.put("m_language", langType);
            } catch (Exception e) {
                logger.error("(m_language)get language error,cause " + e.getMessage(), e);
                logger.warn("@@m_content:" + content);
                logger.warn("the language return " + langType);
                msgMap.put("m_language", "");
            }
            msgMap.put("m_site_id", -1);
            msgMap.put("m_site_name", "");
//            logger.info("跑进1.5");
            Long m_sentiment = GlobalParas.TRS_TOOLS.getMsentiment(content);
            msgMap.put("m_sentiment", m_sentiment);
            msgMap.put("m_importance", -1);
//            logger.info("跑进1.6");
            String[] industry = GlobalParas.TRS_TOOLS.getMCatagoryIndustry(content);
            msgMap.put("m_category_industry", industry);
            if (null != nameIndex.get("PVNUM")) {
                if (null != dataArr[nameIndex.get("PVNUM")]) {
                    String m_pv_cnt = (dataArr[nameIndex.get("PVNUM")]).toString();
                    if (null != m_pv_cnt && !m_pv_cnt.trim().isEmpty() && !"null".equals(m_pv_cnt)) {
                        try {
                            msgMap.put("m_pv_cnt", (String) dataArr[nameIndex.get("PVNUM")]);//PVNUM
                        } catch (Exception e) {
                            logger.error("m_pv_cnt is : " + m_pv_cnt + e, e);
                        }
                    } else {
                        msgMap.put("m_pv_cnt", -1);
                    }
                } else {
                    msgMap.put("m_pv_cnt", -1);
                }
            } else {
                msgMap.put("m_pv_cnt", -1);
            }
            if (null != nameIndex.get("UVNUM")) {
                if (null != dataArr[nameIndex.get("UVNUM")]) {
                    String m_uv_cnt = (dataArr[nameIndex.get("UVNUM")]).toString();
                    if (null != m_uv_cnt && !m_uv_cnt.trim().isEmpty() && !"null".equals(m_uv_cnt)) {
                        try {
                            msgMap.put("m_uv_cnt", Long.valueOf(m_uv_cnt));//UVNUM
                        } catch (Exception e) {
                            logger.error("m_uv_cnt is : " + m_uv_cnt + e, e);
                        }
                    } else {
                        msgMap.put("m_uv_cnt", -1);
                    }
                } else {
                    msgMap.put("m_uv_cnt", -1);
                }
            } else {
                msgMap.put("m_uv_cnt", -1);
            }
            if (null != nameIndex.get("JOINNUM")) {
                if (null != dataArr[nameIndex.get("JOINNUM")]) {
                    if (null != (dataArr[nameIndex.get("JOINNUM")]).toString()) {
                        String m_join_cnt = (dataArr[nameIndex.get("JOINNUM")]).toString();
                        if (null != m_join_cnt && !m_join_cnt.trim().isEmpty() && !"null".equals(m_join_cnt)) {
                            try {
                                msgMap.put("m_join_cnt", Long.valueOf(m_join_cnt));//JOINNUM
                            } catch (Exception e) {
                                logger.error("m_join_cnt is : " + m_join_cnt + e, e);
                            }
                        } else {
                            msgMap.put("m_join_cnt", -1);
                        }
                    } else {
                        msgMap.put("m_join_cnt", -1);
                    }
                } else {
                    msgMap.put("m_join_cnt", -1);
                }
            } else {
                msgMap.put("m_join_cnt", -1);
            }
            if (null != nameIndex.get("SHARENUM")) {
                if (null != dataArr[nameIndex.get("SHARENUM")]) {
                    if (null != (dataArr[nameIndex.get("SHARENUM")]).toString()) {
                        String m_forward_cnt = (dataArr[nameIndex.get("SHARENUM")]).toString();
                        if (null != m_forward_cnt && !m_forward_cnt.trim().isEmpty() && !"null".equals(m_forward_cnt)) {
                            try {
                                msgMap.put("m_forward_cnt", Long.valueOf(m_forward_cnt));//SHARENUM
                            } catch (Exception e) {
                                logger.error("m_forward_cnt is : " + m_forward_cnt + e, e);
                            }
                        } else {
                            msgMap.put("m_forward_cnt", -1);
                        }
                    } else {
                        msgMap.put("m_forward_cnt", -1);
                    }
                } else {
                    msgMap.put("m_forward_cnt", -1);
                }
            } else {
                msgMap.put("m_forward_cnt", -1);
            }
            if (null != nameIndex.get("REPLYNUM")) {
                if (null != dataArr[nameIndex.get("REPLYNUM")]) {
                    if (null != (dataArr[nameIndex.get("REPLYNUM")]).toString()) {
                        String m_reply_cnt = (dataArr[nameIndex.get("REPLYNUM")]).toString();
                        if (null != m_reply_cnt && !m_reply_cnt.trim().isEmpty() && !"null".equals(m_reply_cnt)) {
                            try {
                                msgMap.put("m_reply_cnt", Long.valueOf(m_reply_cnt));//REPLYNUM
                            } catch (Exception e) {
                                logger.error("m_reply_cnt is : " + m_reply_cnt + e, e);
                            }
                        } else {
                            msgMap.put("m_reply_cnt", -1);
                        }
                    } else {
                        msgMap.put("m_reply_cnt", -1);
                    }
                } else {
                    msgMap.put("m_reply_cnt", -1);
                }
            } else {
                msgMap.put("m_reply_cnt", -1);
            }
            
            if (null != nameIndex.get("UPLOADTIME")) {
                logger.debug("moon"+nameIndex.get("UPLOADTIME").toString());
                if (null != (String) dataArr[nameIndex.get("UPLOADTIME")] && !((String) dataArr[nameIndex.get("UPLOADTIME")]).trim().isEmpty()) {
                    logger.debug("candy"+(String) dataArr[nameIndex.get("UPLOADTIME")]);
                    msgMap.put("m_upload_time", TimeFormat.dateToStamp((String) dataArr[nameIndex.get("UPLOADTIME")] ));
                } else {
                    logger.debug("cake");
                    msgMap.put("m_upload_time", "null");
                }
            }else{
                logger.debug("duck");
                msgMap.put("m_upload_time", "null");
            }   
            
            if (null != nameIndex.get("YWLOCATION")) {
                if (null != (String) dataArr[nameIndex.get("YWLOCATION")]) {
                    msgMap.put("m_topnews_location", (String) dataArr[nameIndex.get("YWLOCATION")]);
                } else {
                    msgMap.put("m_topnews_location", "null");
                }

            } else {
                msgMap.put("m_topnews_location", "null");
            }    
            
            if (null != nameIndex.get("SYLOCATION")) {
                if (null != (String) dataArr[nameIndex.get("SYLOCATION")]) {
                    msgMap.put("m_website_location", (String) dataArr[nameIndex.get("SYLOCATION")]);
                } else {
                    msgMap.put("m_website_location", "null");
                }

            } else {
                msgMap.put("m_website_location", "null");
            }    
            
            
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
//            logger.info("跑完1");
            return msgMap;
            
        } catch (Exception ex) {
            logger.error(ex.getStackTrace(), ex);
            return null;
        }
    }

    public static Map<String, Object> commentParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        String type = (String) dataArr[nameIndex.get("msg_type")];
        if ("4".equals(type)) {
            try {
                msgMap.put("m_url_domain", (String) dataArr[nameIndex.get("DOMAIN")]);
                String m_like_cnt = (dataArr[nameIndex.get("LIKENUM")]).toString();
                if (null != m_like_cnt && !m_like_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_like_cnt)) {
                    try {
                        msgMap.put("m_like_cnt", Long.valueOf(m_like_cnt));
                    } catch (Exception e) {
                        logger.error("m_like_cnt is : " + m_like_cnt + e, e);
                        msgMap.put("m_like_cnt", -1);
                    }
                }
                msgMap.put("g_channel", (String) dataArr[nameIndex.get("POSTCHANNEL")]);
                msgMap.put("g_ch_key", new String(Base64.decodeFast((String) dataArr[nameIndex.get("POSTID")]), "utf-8"));
                msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
                msgMap.put("m_root_g_ch_key", new String(Base64.decodeFast((String) dataArr[nameIndex.get("ORIGINURL")]), "utf-8"));
//                msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
                String publishTime = null;
                try {
                    publishTime = (String) dataArr[nameIndex.get("POSTTIME")];
                    if (null != publishTime && !publishTime.trim().isEmpty()) {
                        msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                    } else {
                        msgMap.put("m_publish_time", -1);
                        logger.error("msg_type is 4 and invaild publish_time for loading and the data is:" + publishTime);
                    }
                } catch (Exception e) {
                    logger.error(e, e);
                    msgMap.put("m_publish_time", -1);
                    logger.error("msg_type is 4 and invaild publish_time for loading and the data is:" + publishTime);
                }
                
                if (null != nameIndex.get("key")) {
                    String key = ((dataArr[nameIndex.get("key")]).toString());
                    if (null != key && !key.trim().isEmpty() && !"null".equalsIgnoreCase(key)) {
                        msgMap.put("key", key);
                    }else {
                        msgMap.put("key", "");
                    }
                } else {
                    logger.error("key doesn't exist");
                    msgMap.put("key", "");
                }
 
            String gt = "";
            if (null != nameIndex.get("gt")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("gt")] && "null"!= ((String)dataArr[nameIndex.get("gt")]) && ""!= ((String)dataArr[nameIndex.get("gt")]).trim()) {//判断该字段有没有值
                    gt = (String) dataArr[nameIndex.get("gt")];
                    msgMap.put("m_gather_time", gt);
                } else {
                    msgMap.put("m_gather_time", -1);
                    logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
                }
            } else {
                msgMap.put("m_gather_time", -1);
                logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
            }  
                
                return msgMap;
            } catch (Exception e) {
                logger.error(e, e);
                return null;
            }
        }
        try {
            msgMap.put("m_url_domain", (String) dataArr[nameIndex.get("DOMAIN")]);
            String url = new String(Base64.decodeFast((String) dataArr[nameIndex.get("ORIGINURL")]), "utf-8");
            msgMap.put("m_url", url);
            msgMap.put("g_channel", (String) dataArr[nameIndex.get("POSTCHANNEL")]);
            msgMap.put("g_ch_key", new String(Base64.decodeFast((String) dataArr[nameIndex.get("POSTID")]), "utf-8"));
            msgMap.put("m_parent_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("FPOSTID")]), "utf-8"));
            String publishTime = null;
            try {
                publishTime = (String) dataArr[nameIndex.get("POSTTIME")];
                if (null != publishTime && !publishTime.trim().isEmpty()) {
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_is_pt_generated", 0);
                } else {
                    msgMap.put("m_publish_time", -1);
                    msgMap.put("m_is_pt_generated", 1);
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_publish_time", -1);
                msgMap.put("m_is_pt_generated", 0);
            }
            
            String gt = "";
            if (null != nameIndex.get("gt")) {//判断有没有该字段,字符串为""不代表为null
                if (null != (String) dataArr[nameIndex.get("gt")] && "null"!= ((String)dataArr[nameIndex.get("gt")]) && ""!= ((String)dataArr[nameIndex.get("gt")]).trim()) {//判断该字段有没有值
                    gt = (String) dataArr[nameIndex.get("gt")];
                    msgMap.put("m_gather_time", gt);
                } else {
                    msgMap.put("m_gather_time", -1);
                    logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
                }
            } else {
                msgMap.put("m_gather_time", -1);
                logger.error("msg_type = 2 news_comment invalid gt and data is:" + gt );
            }  
                    
            msgMap.put("m_title", "");
            String content = new String(Base64.decodeFast((String) dataArr[nameIndex.get("POSTCONT")]), "utf-8");//TEXT
            msgMap.put("m_content", content);
            msgMap.put("u_g_ch_key", (String) dataArr[nameIndex.get("USERID")]);
           
            String ip = null;
            if (null != nameIndex.get("POSTIP")) {
                ip = ((dataArr[nameIndex.get("POSTIP")]).toString());
                if (null != ip && !ip.trim().isEmpty() && !"null".equalsIgnoreCase(ip)) {
                        msgMap.put("u_send_ip",ip);
                }else {
                    msgMap.put("u_send_ip","null");
                }
            } else {
                msgMap.put("u_send_ip", "null");
            }
            if (null != ip && !ip.trim().isEmpty()&& !"null".equalsIgnoreCase(ip)) {
                int[] addrNum = GetIpTools.getIpAddr(ip);
                if (addrNum[1] < 1000 && addrNum[1] > 100) {
                    msgMap.put("u_loc_county", -1);
                    msgMap.put("u_loc_province", -1);
                } else {
                    msgMap.put("u_loc_county", addrNum[0]);
                    msgMap.put("u_loc_province", Integer.valueOf(addrNum[1] + "0000"));
                }
            } else {
                msgMap.put("u_loc_county", -1);
                msgMap.put("u_loc_province", -1);
            }
            
            msgMap.put("mo_status", (String) dataArr[nameIndex.get("POSTSTATUS")]);
            String mo_time = (String) dataArr[nameIndex.get("POSTDELTIME")];
            if (null != mo_time && !mo_time.trim().isEmpty() && !"null".equalsIgnoreCase(mo_time)) {
                try {
                    msgMap.put("mo_time", TimeFormat.dateToStamp(mo_time));
                } catch (Exception e) {
                    logger.error("mo_time is : " + mo_time + e, e);
                    msgMap.put("mo_time", "null");
                }
            }else{
                msgMap.put("mo_time", "null");
            }
            
            msgMap.put("m_root_g_ch_key", new String(Base64.decodeFast((String) dataArr[nameIndex.get("ORIGINURL")]), "utf-8"));
            msgMap.put("g_extract_version", 0);
            msgMap.put("m_insert_time", -1);
            msgMap.put("m_update_time", -1);
            String langType = "";
            try {
                LangIdentifyTool langtool = new LangIdentifyTool();
                langtool.initText(content);
                langType = langtool.getLangType();
                msgMap.put("m_language", langType);
            } catch (Exception e) {
                logger.error("(m_language)get language error,cause " + e.getMessage(), e);
                logger.warn("@@m_content:" + content);
                logger.warn("the language return " + langType);
                msgMap.put("m_language", "");
            }
            msgMap.put("m_site_id", -1);
            String domain = (String) dataArr[nameIndex.get("DOMAIN")];
            String name = GlobalParas.SITE_NAME.get(domain);
            if (null != name && !name.trim().isEmpty()) {
                msgMap.put("m_site_name", name);
            } else {
                msgMap.put("m_site_name", "");
//                logger.info("unknow domain: " + domain);
            }

            msgMap.put("u_name", "");
            
            if (null != nameIndex.get("LIKENUM")) {
                String m_like_cnt = ((dataArr[nameIndex.get("LIKENUM")]).toString());
                if (null != m_like_cnt && !m_like_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_like_cnt)) {
                    try {
                        msgMap.put("m_like_cnt", Long.valueOf(m_like_cnt));
                    } catch (Exception e) {
                        logger.error("m_like_cnt is : " + m_like_cnt + e, e);
                        msgMap.put("m_like_cnt", -1);
                    }
                }
            } else {
                msgMap.put("m_like_cnt", -1);
            }
                 

         
            msgMap.put("m_trampled_cnt", -1);
            msgMap.put("m_recommend_cnt", -1);
            msgMap.put("m_sealed_cnt", -1);
            msgMap.put("m_sealed_cont", new String[0]);
            msgMap.put("m_like_user_cnt", -1);
//            logger.info("跑进2.1");
            msgMap.put("m_keywords", GlobalParas.TRS_TOOLS.getMKeyWordList(content));
//            logger.info("跑进2.2");
            HashMap[] keyVector = GlobalParas.TRS_TOOLS.getMKeyWordVector(url);
            msgMap.put("m_keyword_vector", Arrays.toString(keyVector));
//            HashMap[] vmmap = new HashMap[1];
//            HashMap vm = new HashMap();
//            vm.put("v", "");
//            vm.put("w", "");
//            vmmap[0] = vm;
//            logger.info("跑进2.3");
            HashMap<String, HashMap[]> mxxv = GlobalParas.TRS_TOOLS.getMXXVector(content);
            msgMap.put("m_person_vector", Arrays.toString(mxxv.get("person")));
            msgMap.put("m_organization_vector", Arrays.toString(mxxv.get("organization")));
            msgMap.put("m_region_vector", Arrays.toString(mxxv.get("region")));
            msgMap.put("m_country_vector", Arrays.toString(mxxv.get("countries")));//省份
            msgMap.put("m_province_vector", Arrays.toString(mxxv.get("provinces")));//国家
//            logger.info("跑进2.4");
            Long m_sentiment = GlobalParas.TRS_TOOLS.getMsentiment(content);
            msgMap.put("m_sentiment", m_sentiment);
            msgMap.put("m_importance", -1);
            msgMap.put("m_title_sim_tag", "");
            msgMap.put("m_title_sim_rank", -1);
            msgMap.put("m_content_len", content.length());
            msgMap.put("m_cont_sim_tag", GenerateMD5.string2MD5(content));
            msgMap.put("m_cont_sim_rank", RemoveDuplicate.getQCId(GenerateMD5.string2MD5(content))[0]);
            msgMap.put("m_site_location", 0);
//            logger.info("跑进2.5");
            String[] industry = GlobalParas.TRS_TOOLS.getMCatagoryIndustry(content);
            msgMap.put("m_category_industry", industry);
//            logger.info("跑进2.6");
            HashMap<String, String[]> mxx = GlobalParas.TRS_TOOLS.getMXX(content);
            msgMap.put("m_regions", mxx.get("region"));
            msgMap.put("m_countries", mxx.get("country"));//省份
            msgMap.put("m_provinces", mxx.get("province"));//国家
            msgMap.put("m_organizations", mxx.get("organization"));
            msgMap.put("m_persons", mxx.get("person"));
            Map<String, Integer> ymdh = TimeFormat.getYMDH(TimeFormat.dateToStamp(publishTime));
            msgMap.put("m_year", ymdh.get("year"));
            msgMap.put("m_month", ymdh.get("month"));
            msgMap.put("m_day", ymdh.get("day"));
            msgMap.put("m_hour", ymdh.get("hour"));
            msgMap.put("g_asp", (String) dataArr[nameIndex.get("DOMAIN")]);
       
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
           
            if (null != nameIndex.get("key")) {
                String key = ((dataArr[nameIndex.get("key")]).toString());
                if (null != key && !key.trim().isEmpty() && !"null".equalsIgnoreCase(key)) {
                    msgMap.put("key", key);
                }else {
                    msgMap.put("key", "");
                }
            } else {
                logger.error("key doesn't exist");
                msgMap.put("key", "");
            }
//            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
//            logger.info("跑完2");
            return msgMap;
         
        } catch (Exception e) {
            logger.error(e, e);
            return null;
        }

    }

    /**
     * 按tp_user_news 方式解析
     *
     * @param dataArr 数据包
     * @param nameIndex 字段位置对应关系
     * @return
     */
    public static Map<String, Object> userParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        try {
            msgMap.put("u_url_domain", (String) dataArr[nameIndex.get("DOMAIN")]);
            msgMap.put("g_ch_key", new String(Base64.decodeFast((String) dataArr[nameIndex.get("USERID")]), "utf-8"));
            if (null != nameIndex.get("NAME")) {
                if (null != (String) dataArr[nameIndex.get("NAME")]) {
                    msgMap.put("u_name", new String(Base64.decodeFast((String) dataArr[nameIndex.get("NAME")]), "utf-8"));
                } else {
                    msgMap.put("u_name", "");
                }

            } else {
                msgMap.put("u_name", "");
            }
            if (null != nameIndex.get("BRIEFINFO")) {
                if (null != (String) dataArr[nameIndex.get("BRIEFINFO")]) {
                    msgMap.put("u_description", new String(Base64.decodeFast((String) dataArr[nameIndex.get("BRIEFINFO")]), "utf-8"));
                } else {
                    msgMap.put("u_description", "null");
                }

            } else {
                msgMap.put("u_description", "null");
            }
            
            String url = null;
            if (null != nameIndex.get("HEADURL")) {
                url = (String) dataArr[nameIndex.get("HEADURL")];
                if (null !=  url && !url.trim().isEmpty() && !"null".equals(url)) {
                    msgMap.put("u_icon_url", new String(Base64.decodeFast((String) dataArr[nameIndex.get("HEADURL")]), "utf-8"));
                } else {
                    msgMap.put("u_icon_url", "null");
                }
            } else {
                msgMap.put("u_icon_url", "null");
            }
            
            String u_register_time = (String) dataArr[nameIndex.get("REGISTERTIME")];
            if (null != u_register_time && !u_register_time.trim().isEmpty() && !"null".equalsIgnoreCase(u_register_time)) {
                try {
                    msgMap.put("u_register_time", TimeFormat.dateToStamp(u_register_time));
                } catch (Exception e) {
                    logger.error("u_register_time is : " + u_register_time + e, e);
                    msgMap.put("u_register_time", "null");
                }
            }else{
                msgMap.put("u_register_time", "null");
            }
            
            
            msgMap.put("u_register_email", (String) dataArr[nameIndex.get("EMAIL")]);
            if (null != nameIndex.get("PHONE")) {
                if (null != (String) dataArr[nameIndex.get("PHONE")]) {
                    msgMap.put("u_register_phone", (String) dataArr[nameIndex.get("PHONE")]);
                } else {
                    msgMap.put("u_register_phone", "null");
                }

            } else {
                msgMap.put("u_register_phone", "null");
            }
            if (null != nameIndex.get("PLATINFO")) {
                if (null != (String) dataArr[nameIndex.get("PLATINFO")]) {
                    msgMap.put("u_platinfo", new String(Base64.decodeFast((String) dataArr[nameIndex.get("PLATINFO")]), "utf-8"));
                } else {
                    msgMap.put("u_platinfo", "null");
                }

            } else {
                msgMap.put("u_platinfo", "null");
            }
         
          if (null != nameIndex.get("USERSTATE")) {
            String uo_status = (String) dataArr[nameIndex.get("USERSTATE")];
            if (null != uo_status && !uo_status.trim().isEmpty() && !"null".equalsIgnoreCase(uo_status)) {
                try {
                    msgMap.put("uo_status", uo_status);
                } catch (Exception e) {
                    logger.error("uo_status is : " + u_register_time + e, e);
                    msgMap.put("uo_status", -1);
                }
            }
          }else {
              msgMap.put("uo_status", "null");
          }
            
          if (null != nameIndex.get("PROCESSINGTIME")) {
            String uo_time = (String) dataArr[nameIndex.get("PROCESSINGTIME")];
            if (null != uo_time && !uo_time.trim().isEmpty() && !"null".equalsIgnoreCase(uo_time)) {
                try {
                    msgMap.put("uo_time", TimeFormat.dateToStamp(uo_time));
                } catch (Exception e) {
                    logger.error("uo_time is : " + u_register_time + e, e);
                    msgMap.put("uo_time", "null");
                }
            }
          }else {
              msgMap.put("uo_time", "null");
          }
    
            msgMap.put("u_reg_loc_province", -1);
            msgMap.put("u_reg_loc_county", -1);
            msgMap.put("g_asp", (String) dataArr[nameIndex.get("DOMAIN")]);
            msgMap.put("u_insert_time", -1);
            
            String gt = "";
            if (null != nameIndex.get("gt")) {
                  gt = ((dataArr[nameIndex.get("gt")]).toString());
                  if (null != gt && !gt.trim().isEmpty()) {
                      msgMap.put("u_gather_time", gt);
                  }else {
                      msgMap.put("u_gather_time", -1);
                      logger.error("illegal news_user_gt for loading and data is:" + gt);
                  }
              } else {
                  msgMap.put("u_gather_time", -1);
                  logger.error("illegal news_user_gt for loading and data is:" + gt);
              }      
            msgMap.put("u_update_time", -1);
            msgMap.put("u_icon_path", getFilePath(new String[]{url}, (String) dataArr[nameIndex.get("gt")], "user", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")])[0]);
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
//            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
 
            

            if (null != nameIndex.get("key")) {
                String key = ((dataArr[nameIndex.get("key")]).toString());
                if (null != key && !key.trim().isEmpty()) {
                    msgMap.put("key", key);
                }else {
                    msgMap.put("key", "");
                }
            } else {
                logger.error("key doesn't exist");
                msgMap.put("key", "");
            }
            return msgMap;
        } catch (Exception ex) {
            logger.error(ex, ex);
            return null;
        }

    }

     /**
     * t_appstore 方式解析 
     *
     * @param dataArr 数据包
     * @param nameIndex 字段位置对应关系
     * @return
     */
    public static Map<String, Object> appStoreParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        try {
            msgMap.put("m_appstore_name", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPSTORENAME")]), "utf-8"));
            msgMap.put("g_ch_key", (String) dataArr[nameIndex.get("APPSTOREID")]);
            if (null != nameIndex.get("WECHATID")) {
                if (null != (String) dataArr[nameIndex.get("WECHATID")]) {
                    msgMap.put("m_wechat_name", (String) dataArr[nameIndex.get("WECHATID")]);
                } else {
                    msgMap.put("m_wechat_name", "");
                }

            } else {
                msgMap.put("m_wechat_name", "");
            }    
            msgMap.put("g_asp", (String) dataArr[nameIndex.get("COMPANY")]);       
            String m_appstore_logo_url = new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPSTORELOGO")]), "utf-8");
            msgMap.put("m_appstore_logo_url",m_appstore_logo_url);
            if (null != nameIndex.get("APPSTOREINFO")) {
                if (null != (String) dataArr[nameIndex.get("APPSTOREINFO")]) {
                    msgMap.put("m_appstore_info", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPSTOREINFO")]), "utf-8"));
                } else {
                    msgMap.put("m_appstore_info", "");
                }

            } else {
                msgMap.put("m_appstore_info", "");
            }
//            ??????????????????????????????????????????????????????????????????????????
            String publishTime = (String) dataArr[nameIndex.get("PUBLISHTIME")];//PUBLISHTIME
            try {
                if (null == publishTime || publishTime.trim().isEmpty()) {
                    msgMap.put("m_gather_time", -1);
                    msgMap.put("m_is_pt_generated", 0);
                } else {
                    msgMap.put("m_gather_time", TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_is_pt_generated", 1);
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_gather_time", -1);
                msgMap.put("m_is_pt_generated", 0);
                msgMap.put("m_publish_time", -1);
            }            
            String snapshotTime = (String) dataArr[nameIndex.get("SNAPSHOTTIME")];//SNAPSHOTTIME
            msgMap.put("m_snapshot_time", TimeFormat.dateToStamp(snapshotTime));
            if (null != nameIndex.get("POPULARAPPLIST")) {//判断有没有该字段,字符串为""不代表为null
                if (null !=((String)dataArr[nameIndex.get("POPULARAPPLIST")]) && !((String)dataArr[nameIndex.get("POPULARAPPLIST")]).trim().isEmpty() && !"null".equalsIgnoreCase(((String)dataArr[nameIndex.get("POPULARAPPLIST")])) && !"[]".equals((String)dataArr[nameIndex.get("POPULARAPPLIST")])) {//判断该字段有没有值
                    msgMap.put("POPULARAPPLIST",JSONArray.fromObject(dataArr[nameIndex.get("POPULARAPPLIST")]).toArray(new String[JSONArray.fromObject(dataArr[nameIndex.get("POPULARAPPLIST")]).size()]));
                } else {
                    msgMap.put("m_popular_lists", new String[0]);
                }

            } else {
                msgMap.put("m_popular_lists", new String[0]);
            }    
            if (null != nameIndex.get("NEWPOPULARAPPLIST")) {
                if (null !=((String)dataArr[nameIndex.get("NEWPOPULARAPPLIST")]) && !((String)dataArr[nameIndex.get("NEWPOPULARAPPLIST")]).trim().isEmpty() && !"null".equalsIgnoreCase(((String)dataArr[nameIndex.get("NEWPOPULARAPPLIST")])) && !"[]".equals((String)dataArr[nameIndex.get("NEWPOPULARAPPLIST")])) {
                    msgMap.put("m_new_popular_lists", JSONArray.fromObject(dataArr[nameIndex.get("NEWPOPULARAPPLIST")]).toArray(new String[JSONArray.fromObject(dataArr[nameIndex.get("NEWPOPULARAPPLIST")]).size()]));
                } else {
                    msgMap.put("m_new_popular_lists", new String[0]);
                }

            } else {
                msgMap.put("m_new_popular_lists", new String[0]);
            } 
            if (null != nameIndex.get("HOTSEARCH")) {
                if (null !=((String)dataArr[nameIndex.get("HOTSEARCH")]) && !((String)dataArr[nameIndex.get("HOTSEARCH")]).trim().isEmpty() && !"null".equalsIgnoreCase(((String)dataArr[nameIndex.get("HOTSEARCH")])) && !"[]".equals((String)dataArr[nameIndex.get("HOTSEARCH")])) {
                    msgMap.put("m_hotsearch_lists", JSONArray.fromObject(dataArr[nameIndex.get("HOTSEARCH")]).toArray(new String[JSONArray.fromObject(dataArr[nameIndex.get("HOTSEARCH")]).size()]));
                } else {
                    msgMap.put("m_hotsearch_lists", new String[0]);
                }

            } else {
                msgMap.put("m_hotsearch_lists", new String[0]);
            }    
            String mo_status = null;
            try {
                mo_status = (String) dataArr[nameIndex.get("ISDEL")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_status", Long.valueOf((String) dataArr[nameIndex.get("ISDEL")]));//ISDEL
                } else {
                    msgMap.put("mo_status", "null");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_status is :" + mo_status + e, e);
                msgMap.put("mo_status", "null");//ISDEL
            }           
            String mo_time = null;
            try {
                mo_time = (String) dataArr[nameIndex.get("DELTIME")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_time", Long.valueOf((String) dataArr[nameIndex.get("DELTIME")]));//DELTIME
                } else {
                    msgMap.put("mo_time", "");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_time is :" + mo_time + e, e);
                msgMap.put("mo_time", "");//ISDEL
            }
            msgMap.put("m_appstore_logo_file", getFilePathSpecial(new String[]{m_appstore_logo_url},publishTime, "jpg", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")])[0]);
            msgMap.put("m_insert_time", -1);
            if (null != publishTime && !publishTime.trim().isEmpty()) {
                try {
                    Map<String, Integer> ymdh = TimeFormat.getYMDH(TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_year", ymdh.get("year"));
                    msgMap.put("m_month", ymdh.get("month"));
                    msgMap.put("m_day", ymdh.get("day"));
                    msgMap.put("m_hour", ymdh.get("hour"));
                } catch (Exception e) {
                    logger.error("publishTime is: " + publishTime + e, e);
                    msgMap.put("m_year", -1);
                    msgMap.put("m_month", -1);
                    msgMap.put("m_day", -1);
                    msgMap.put("m_hour", -1);
                }
            }
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
            return msgMap;
        } catch (Exception ex) {
            logger.error(ex, ex);
            return null;
        }
    }
    
     /**
     * t_app_category 方式解析 
     *
     * @param dataArr 数据包
     * @param nameIndex 字段位置对应关系
     * @return
     */
    public static Map<String, Object> appCategoryParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        try {
            msgMap.put("m_app_category_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPCATEGORYID")]), "utf-8"));
            msgMap.put("g_ch_key", (String) dataArr[nameIndex.get("APPSTOREID")]);
            msgMap.put("m_app_category", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPCATEGORY")]), "utf-8"));
            if (null != nameIndex.get("CATEGORYINFO")) {
                if (null != (String) dataArr[nameIndex.get("CATEGORYINFO")]) {
                    msgMap.put("m_category_info", new String(Base64.decodeFast((String) dataArr[nameIndex.get("CATEGORYINFO")]), "utf-8"));
                } else {
                    msgMap.put("m_category_info", "");
                }

            } else {
                msgMap.put("m_category_info", "");
            }
            String publishTime = (String) dataArr[nameIndex.get("SNAPSHOTTIME")];//PUBLISHTIME
            try {
                if (null == publishTime || publishTime.trim().isEmpty()) {
                    msgMap.put("m_gather_time", -1);
                    msgMap.put("m_is_pt_generated", 0);
                } else {
                    msgMap.put("m_gather_time", TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_is_pt_generated", 1);
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_gather_time", -1);
                msgMap.put("m_is_pt_generated", 0);
                msgMap.put("m_publish_time", -1);
            }   
            if (null != nameIndex.get("BARDIR")) {
                if (null != (String) dataArr[nameIndex.get("BARDIR")]) {
                    msgMap.put("m_bardir", new String(Base64.decodeFast((String) dataArr[nameIndex.get("BARDIR")]), "utf-8"));
                } else {
                    msgMap.put("m_bardir", "");
                }

            } else {
                msgMap.put("m_bardir", "");
            }
            String mo_status = null;
            try {
                mo_status = (String) dataArr[nameIndex.get("ISDEL")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_status", Long.valueOf((String) dataArr[nameIndex.get("ISDEL")]));//ISDEL
                } else {
                    msgMap.put("mo_status", "");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_status is :" + mo_status + e, e);
                msgMap.put("mo_status", "");//ISDEL
            }           
            String mo_time = null;
            try {
                mo_time = (String) dataArr[nameIndex.get("DELTIME")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_time", Long.valueOf((String) dataArr[nameIndex.get("DELTIME")]));//DELTIME
                } else {
                    msgMap.put("mo_time", "");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_time is :" + mo_time + e, e);
                msgMap.put("mo_time", "");//ISDEL
            }
            String m_app_num = null;
            try {
                m_app_num = (String) dataArr[nameIndex.get("APPNUM")];
                if (null != m_app_num && !m_app_num.trim().isEmpty()) {
                    msgMap.put("m_app_num", Long.valueOf((String) dataArr[nameIndex.get("APPNUM")]));//DELTIME
                } else {
                    msgMap.put("m_app_num", -1);//ISDEL
                }
            } catch (Exception e) {
                logger.error("m_app_num is :" + m_app_num + e, e);
                msgMap.put("m_app_num", -1);//ISDEL
            }
            try {
                if (null == publishTime || publishTime.trim().isEmpty()) {
                    msgMap.put("m_gather_time", -1);
                    msgMap.put("m_is_pt_generated", 0);
                } else {
                    msgMap.put("m_gather_time", TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_is_pt_generated", 1);
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_gather_time", -1);
                msgMap.put("m_is_pt_generated", 0);
                msgMap.put("m_publish_time", -1);
            }   
            if (null != publishTime && !publishTime.trim().isEmpty()) {
                try {
                    Map<String, Integer> ymdh = TimeFormat.getYMDH(TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_year", ymdh.get("year"));
                    msgMap.put("m_month", ymdh.get("month"));
                    msgMap.put("m_day", ymdh.get("day"));
                    msgMap.put("m_hour", ymdh.get("hour"));
                } catch (Exception e) {
                    logger.error("publishTime is: " + publishTime + e, e);
                    msgMap.put("m_year", -1);
                    msgMap.put("m_month", -1);
                    msgMap.put("m_day", -1);
                    msgMap.put("m_hour", -1);
                }
            }
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
            return msgMap;
        } catch (Exception ex) {
            logger.error(ex, ex);
            return null;
        }
    }
    
    
    
    
    
     /**
     * t_app_category 方式解析 
     *
     * @param dataArr 数据包
     * @param nameIndex 字段位置对应关系
     * @return
     */
    public static Map<String, Object> appInfoParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        try {
            msgMap.put("m_app_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPID")]), "utf-8"));
            msgMap.put("m_app_name", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPNAME")]), "utf-8"));
            if (null != nameIndex.get("APPPNAME")) {
                if (null != (String) dataArr[nameIndex.get("APPPNAME")]) {
                    msgMap.put("m_app_pname", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPPNAME")]), "utf-8"));
                } else {
                    msgMap.put("m_app_pname", "");
                }

            } else {
                msgMap.put("m_app_pname", "");
            }
            msgMap.put("g_ch_key", (String) dataArr[nameIndex.get("APPSTOREID")]);
            msgMap.put("m_app_version", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPVERSION")]), "utf-8"));
            msgMap.put("m_app_category_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPCATEGORYID")]), "utf-8"));
            if (null != nameIndex.get("APPINFO")) {
                if (null != (String) dataArr[nameIndex.get("APPINFO")]) {
                    msgMap.put("m_app_info", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPINFO")]), "utf-8"));
                } else {
                    msgMap.put("m_app_info", "");
                }

            } else {
                msgMap.put("m_app_info", "");
            }
            String publishTime = (String) dataArr[nameIndex.get("SNAPSHOTTIME")];//PUBLISHTIME
            try {
                if (null == publishTime || publishTime.trim().isEmpty()) {
                    msgMap.put("m_gather_time", -1);
                    msgMap.put("m_is_pt_generated", 0);
                } else {
                    msgMap.put("m_gather_time", TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_is_pt_generated", 1);
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_gather_time", -1);
                msgMap.put("m_is_pt_generated", 0);
                msgMap.put("m_publish_time", -1);
            }       
            String updateTime = (String) dataArr[nameIndex.get("APPUPDATETIME")];
            try {
                if (null == updateTime || updateTime.trim().isEmpty()) {
                    msgMap.put("m_update_time", "");
                } else {
                    msgMap.put("m_update_time", TimeFormat.dateToStamp(updateTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_update_time", "");
            }   
            String m_app_score = null;
            try {
                m_app_score = (String) dataArr[nameIndex.get("APPSCORE")];
                if (null != m_app_score && !m_app_score.trim().isEmpty()) {
                    msgMap.put("m_app_score", Long.valueOf((String) dataArr[nameIndex.get("APPSCORE")]));
                } else {
                    msgMap.put("m_app_score", -1);
                }
            } catch (Exception e) {
                logger.error("m_app_score is :" + m_app_score + e, e);
                msgMap.put("m_app_score", -1);
            }
            String m_app_usernum = null;
            try {
                m_app_usernum = (String) dataArr[nameIndex.get("APPUERRNUM")];
                if (null != m_app_usernum && !m_app_usernum.trim().isEmpty()) {
                    msgMap.put("m_app_usernum", Long.valueOf((String) dataArr[nameIndex.get("APPUERRNUM")]));
                } else {
                    msgMap.put("m_app_usernum", -1);
                }
            } catch (Exception e) {
                logger.error("m_app_usernum is :" + nameIndex + e, e);
                msgMap.put("m_app_usernum", -1);
            }
            String m_app_size = null;
            try {
                m_app_size = (String) dataArr[nameIndex.get("APPSIZE")];
                if (null != m_app_size && !m_app_size.trim().isEmpty()) {
                    msgMap.put("m_app_size", Long.valueOf((String) dataArr[nameIndex.get("APPSIZE")]));
                } else {
                    msgMap.put("m_app_size", "");
                }
            } catch (Exception e) {
                logger.error("m_app_size is :" + m_app_size + e, e);
                msgMap.put("m_app_size", "");
            }
            if (null != nameIndex.get("APPOWNER")) {
                if (null != (String) dataArr[nameIndex.get("APPOWNER")]) {
                    msgMap.put("m_app_owner", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPOWNER")]), "utf-8"));
                } else {
                    msgMap.put("m_app_owner", "");
                }

            } else {
                msgMap.put("m_app_owner", "");
            }
            if (null != nameIndex.get("APPINSTALLREQUEST")) {
                if (null != (String) dataArr[nameIndex.get("APPINSTALLREQUEST")]) {
                    msgMap.put("m_app_installrequest", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPINSTALLREQUEST")]), "utf-8"));
                } else {
                    msgMap.put("m_app_installrequest", "");
                }

            } else {    
                msgMap.put("m_app_installrequest", "");
            }   
            String[] snapshotUrls = {};
            if(null != nameIndex.get("APPSNAPSHOTURLS")){
                if(null!=((String)dataArr[nameIndex.get("APPSNAPSHOTURLS")]) && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("APPSNAPSHOTURLS")]) && !((String)dataArr[nameIndex.get("APPSNAPSHOTURLS")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("APPSNAPSHOTURLS")])){
                    snapshotUrls = baseUrlsToUrls((String) dataArr[nameIndex.get("APPSNAPSHOTURLS")]);    
                    msgMap.put("m_app_snapshot_urls", snapshotUrls);
                } else {
                    msgMap.put("m_app_snapshot_urls", new String[0]);
                }
            } else {
                msgMap.put("m_app_snapshot_urls", new String[0]);
            } 
            if (null != nameIndex.get("USERIDLIST")) {
                if (null!=((String)dataArr[nameIndex.get("USERIDLIST")]) && !"null".equalsIgnoreCase((String)dataArr[nameIndex.get("USERIDLIST")]) && !((String)dataArr[nameIndex.get("USERIDLIST")]).trim().isEmpty() && !"[]".equals((String)dataArr[nameIndex.get("USERIDLIST")])) {
                    msgMap.put("m_userid_lists", (JSONArray.fromObject(dataArr[nameIndex.get("USERIDLIST")]).toArray(new String[JSONArray.fromObject(dataArr[nameIndex.get("USERIDLIST")]).size()])));
                } else {
                    msgMap.put("m_userid_lists", new String[0]);
                }
            } else {
                msgMap.put("m_userid_lists", new String[0]);
            }             
            String m_user_num = null;
            try {
                m_user_num = (String) dataArr[nameIndex.get("USERNUM")];
                if (null != m_user_num && !m_user_num.trim().isEmpty()) {
                    msgMap.put("m_user_num", Long.valueOf((String) dataArr[nameIndex.get("USERNUM")]));
                } else {
                    msgMap.put("m_user_num", -1);
                }
            } catch (Exception e) {
                logger.error("m_user_num is :" + m_app_usernum + e, e);
                msgMap.put("m_user_num", -1);
            }
            String m_app_logo_url = new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPLOGOURL")]), "utf-8");
            msgMap.put("m_app_logo_url",m_app_logo_url );
            msgMap.put("m_app_state", (String) dataArr[nameIndex.get("APPSTATE")]);
            msgMap.put("m_is_harm", Long.valueOf((String) dataArr[nameIndex.get("APPHARMSTATE")]));
            if (null != nameIndex.get("APPHARMMSG")) {
                if (null != (String) dataArr[nameIndex.get("APPHARMMSG")]) {
                    msgMap.put("m_is_harm_msg", (String) dataArr[nameIndex.get("APPHARMMSG")]);
                } else {
                    msgMap.put("m_is_harm_msg", "");
                }
            } else {
                msgMap.put("m_is_harm_msg", "");
            }    
            if (null != nameIndex.get("APPIP")) {
                if (null != (String) dataArr[nameIndex.get("APPIP")]) {
                    msgMap.put("m_app_ip", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPIP")]), "utf-8"));
                } else {
                    msgMap.put("m_app_ip", "");
                }
            } else {
                msgMap.put("m_app_ip", "");
            }   
            if (null != nameIndex.get("APPIPLOCAL")) {
                if (null != (String) dataArr[nameIndex.get("APPIPLOCAL")]) {
                    msgMap.put("m_app_iplocal", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPIPLOCAL")]), "utf-8"));
                } else {
                    msgMap.put("m_app_iplocal", "");
                }

            } else {
                msgMap.put("m_app_iplocal", "");
            }   
            String m_app_download_url = new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPDOWNLOADURL")]), "utf-8");
            if (null != nameIndex.get("APPDOWNLOADURL")) {
                if (null != (String) dataArr[nameIndex.get("APPDOWNLOADURL")]) {
                    msgMap.put("m_app_download_url", m_app_download_url);
                } else {
                    msgMap.put("m_app_download_url", "");
                }

            } else {
                msgMap.put("m_app_download_url", "");
            }   
            String mo_status = null;
            try {
                mo_status = (String) dataArr[nameIndex.get("ISDEL")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_status", Long.valueOf((String) dataArr[nameIndex.get("ISDEL")]));//ISDEL
                } else {
                    msgMap.put("mo_status", "");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_status is :" + mo_status + e, e);
                msgMap.put("mo_status", "");//ISDEL
            }           
            String mo_time = null;
            try {
                mo_time = (String) dataArr[nameIndex.get("DELTIME")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_time", Long.valueOf((String) dataArr[nameIndex.get("DELTIME")]));//DELTIME
                } else {
                    msgMap.put("mo_time", "");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_time is :" + mo_time + e, e);
                msgMap.put("mo_time", "");//ISDEL
            }  
            msgMap.put("m_app_snapshot_files", getFilePath(snapshotUrls,publishTime,"jpg", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")]));
            msgMap.put("m_app_logo_file", getFilePathSpecial(new String[]{m_app_logo_url},publishTime, "jpg", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")])[0]);
            msgMap.put("m_app_download_file", getFilePathSpecial(new String[]{m_app_download_url},publishTime, "other", (String) dataArr[nameIndex.get("msg_type")],(String) dataArr[nameIndex.get("key")])[0]);
            msgMap.put("m_insert_time", -1);
            if (null != publishTime && !publishTime.trim().isEmpty()) {
                try {
                    Map<String, Integer> ymdh = TimeFormat.getYMDH(TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_year", ymdh.get("year"));
                    msgMap.put("m_month", ymdh.get("month"));
                    msgMap.put("m_day", ymdh.get("day"));
                    msgMap.put("m_hour", ymdh.get("hour"));
                } catch (Exception e) {
                    logger.error("publishTime is: " + publishTime + e, e);
                    msgMap.put("m_year", -1);
                    msgMap.put("m_month", -1);
                    msgMap.put("m_day", -1);
                    msgMap.put("m_hour", -1);
                }
            } 
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
            return msgMap;
        } catch (Exception ex) {
            logger.error(ex, ex);
            return null;
        }
    }
    
    
     /**
     * tp_msg_app_comment 方式解析 
     *
     * @param dataArr 数据包
     * @param nameIndex 字段位置对应关系
     * @return
     */
    public static Map<String, Object> appCommentParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        try {
            msgMap.put("m_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMMENTID")]), "utf-8"));
            msgMap.put("g_ch_key", (String) dataArr[nameIndex.get("APPSTOREID")]);
            msgMap.put("m_app_version", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPVERSION")]), "utf-8"));
            msgMap.put("m_root_app_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPID")]), "utf-8"));
            msgMap.put("m_content", new String(Base64.decodeFast((String) dataArr[nameIndex.get("TEXT")]), "utf-8"));
            String publishTime = (String) dataArr[nameIndex.get("PUBLISHTIME")];//PUBLISHTIME
            try {
                if (null == publishTime || publishTime.trim().isEmpty()) {
                    msgMap.put("m_gather_time", -1);
                    msgMap.put("m_is_pt_generated", 0);
                } else {
                    msgMap.put("m_gather_time", TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_is_pt_generated", 1);
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_gather_time", -1);
                msgMap.put("m_is_pt_generated", 0);
                msgMap.put("m_publish_time", "");
            } 
            String snapshotTime = (String) dataArr[nameIndex.get("SNAPSHOTTIME")];//SNAPSHOTTIME
            msgMap.put("m_snapshot_time", TimeFormat.dateToStamp(snapshotTime));
            if (null != dataArr[nameIndex.get("PRAISEDNUM")]) {
                String m_like_cnt = (String) dataArr[nameIndex.get("PRAISEDNUM")];
                if (null != m_like_cnt && !m_like_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_like_cnt)) {
                    try {
                        msgMap.put("m_like_cnt", Long.valueOf(m_like_cnt));
                    } catch (Exception e) {
                        logger.error("m_like_cnt is : " + m_like_cnt + e, e);
                        msgMap.put("m_like_cnt", -1);
                    }
                }
            } else {
                msgMap.put("m_like_cnt", -1);
            }
            if (null != dataArr[nameIndex.get("POSTNUM")]) {
                String m_reply_cnt = (String) dataArr[nameIndex.get("POSTNUM")];
                if (null != m_reply_cnt && !m_reply_cnt.trim().isEmpty() && !"null".equalsIgnoreCase(m_reply_cnt)) {
                    try {
                        msgMap.put("m_reply_cnt", Long.valueOf(m_reply_cnt));//REPLYNUM
                    } catch (Exception e) {
                        logger.error("m_reply_cnt is : " + m_reply_cnt + e, e);
                    }
                } else {
                    msgMap.put("m_reply_cnt", -1);
                }
            } else {
                msgMap.put("m_reply_cnt", -1);
            }
            if (null != dataArr[nameIndex.get("PUBLISHFLOOR")]) {
                String m_sub_seqno = (String) dataArr[nameIndex.get("PUBLISHFLOOR")];
                if (null != m_sub_seqno && !m_sub_seqno.trim().isEmpty() && !"null".equalsIgnoreCase(m_sub_seqno)) {
                    try {
                        msgMap.put("m_sub_seqno", Long.valueOf(m_sub_seqno));//REPLYNUM
                    } catch (Exception e) {
                        logger.error("m_sub_seqno is : " + m_sub_seqno + e, e);
                    }
                } else {
                    msgMap.put("m_sub_seqno", -1);
                }
            } else {
                msgMap.put("m_sub_seqno", -1);
            }
            String mo_status = null;
            try {
                mo_status = (String) dataArr[nameIndex.get("ISDEL")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_status", Long.valueOf((String) dataArr[nameIndex.get("ISDEL")]));//ISDEL
                } else {
                    msgMap.put("mo_status", "");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_status is :" + mo_status + e, e);
                msgMap.put("mo_status", "");//ISDEL
            }           
            String mo_time = null;
            try {
                mo_time = (String) dataArr[nameIndex.get("DELTIME")];
                if (null != mo_status && !mo_status.trim().isEmpty()) {
                    msgMap.put("mo_time", Long.valueOf((String) dataArr[nameIndex.get("DELTIME")]));//DELTIME
                } else {
                    msgMap.put("mo_time", "");//ISDEL
                }
            } catch (Exception e) {
                logger.error("mo_time is :" + mo_time + e, e);
                msgMap.put("mo_time", "");//ISDEL
            } 
            if (null != publishTime && !publishTime.trim().isEmpty()) {
                try {
                    Map<String, Integer> ymdh = TimeFormat.getYMDH(TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_year", ymdh.get("year"));
                    msgMap.put("m_month", ymdh.get("month"));
                    msgMap.put("m_day", ymdh.get("day"));
                    msgMap.put("m_hour", ymdh.get("hour"));
                } catch (Exception e) {
                    logger.error("publishTime is: " + publishTime + e, e);
                    msgMap.put("m_year", -1);
                    msgMap.put("m_month", -1);
                    msgMap.put("m_day", -1);
                    msgMap.put("m_hour", -1);
                }
            }
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
            return msgMap;
        } catch (Exception ex) {
            logger.error(ex, ex);
            return null;
        }
    }
    
    
    
    /**
     * t_app_developer 方式解析 
     *
     * @param dataArr 数据包
     * @param nameIndex 字段位置对应关系
     * @return
     */
    public static Map<String, Object> appDeveloperParser(Object[] dataArr, Map<String, Integer> nameIndex) {
        Map<String, Object> msgMap = new HashMap<>();
        try {
            msgMap.put("m_app_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPID")]), "utf-8"));
            msgMap.put("g_ch_key", (String) dataArr[nameIndex.get("APPSTOREID")]);
            msgMap.put("m_app_version", new String(Base64.decodeFast((String) dataArr[nameIndex.get("APPVERSION")]), "utf-8"));
            if (null != nameIndex.get("COMPANYNAME")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYNAME")]) {
                    msgMap.put("g_asp", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMPANYNAME")]), "utf-8"));
                } else {
                    msgMap.put("g_asp", "");
                }

            } else {
                msgMap.put("g_asp", "");
            }
            if (null != nameIndex.get("COMPANYCERTIFICATETYPE")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYCERTIFICATETYPE")]) {
                    msgMap.put("m_com_cert_type", (String) dataArr[nameIndex.get("COMPANYCERTIFICATETYPE")]);
                } else {
                    msgMap.put("m_com_cert_type", "");
                }

            } else {
                msgMap.put("m_com_cert_type", "");
            }    
            if (null != nameIndex.get("COMPANYCERTIFICATEID")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYCERTIFICATEID")]) {
                    msgMap.put("m_com_cert_id", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMPANYCERTIFICATEID")]), "utf-8"));
                } else {
                    msgMap.put("m_com_cert_id", "");
                }

            } else {
                msgMap.put("m_com_cert_id", "");
            }
            if (null != nameIndex.get("LEGALNAME")) {
                if (null != (String) dataArr[nameIndex.get("LEGALNAME")]) {
                    msgMap.put("m_legal_name", (String) dataArr[nameIndex.get("LEGALNAME")]);
                } else {
                    msgMap.put("m_legal_name", "");
                }

            } else {
                msgMap.put("m_legal_name", "");
            }   
            if (null != nameIndex.get("COMPANYPHONENUM")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYPHONENUM")]) {
                    msgMap.put("m_com_phone", (String) dataArr[nameIndex.get("COMPANYPHONENUM")]);
                } else {
                    msgMap.put("m_com_phone", "");
                }

            } else {
                msgMap.put("m_com_phone", "");
            }   
            if (null != nameIndex.get("COMPANYPROVINCE")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYPROVINCE")]) {
                    msgMap.put("m_com_province", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMPANYPROVINCE")]), "utf-8"));
                } else {
                    msgMap.put("m_com_province", "");
                }

            } else {
                msgMap.put("m_com_province", "");
            }
            if (null != nameIndex.get("COMPANYCITY")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYCITY")]) {
                    msgMap.put("m_com_city", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMPANYCITY")]), "utf-8"));
                } else {
                    msgMap.put("m_com_city", "");
                }

            } else {
                msgMap.put("m_com_city", "");
            }
            if (null != nameIndex.get("COMPANYDISTRICT")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYDISTRICT")]) {
                    msgMap.put("m_com_county", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMPANYDISTRICT")]), "utf-8"));
                } else {
                    msgMap.put("m_com_county", "");
                }

            } else {
                msgMap.put("m_com_county", "");
            }
            if (null != nameIndex.get("COMPANYDISTRICT")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYDISTRICT")]) {
                    msgMap.put("m_com_county", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMPANYDISTRICT")]), "utf-8"));
                } else {
                    msgMap.put("m_com_county", "");
                }

            } else {
                msgMap.put("m_com_county", "");
            }
            if (null != nameIndex.get("COMPANYDETAILADDRESS")) {
                if (null != (String) dataArr[nameIndex.get("COMPANYDETAILADDRESS")]) {
                    msgMap.put("m_com_address", new String(Base64.decodeFast((String) dataArr[nameIndex.get("COMPANYDETAILADDRESS")]), "utf-8"));
                } else {
                    msgMap.put("m_com_address", "");
                }

            } else {
                msgMap.put("m_com_address", "");
            }
            if (null != nameIndex.get("PERSIONNAME")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONNAME")]) {
                    msgMap.put("u_name", new String(Base64.decodeFast((String) dataArr[nameIndex.get("PERSIONNAME")]), "utf-8"));
                } else {
                    msgMap.put("u_name", "");
                }

            } else {
                msgMap.put("u_name", "");
            }
            if (null != nameIndex.get("PERSIONCERTIFICATETYPE")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONCERTIFICATETYPE")]) {
                    msgMap.put("u_cert_type", (String) dataArr[nameIndex.get("PERSIONCERTIFICATETYPE")]);
                } else {
                    msgMap.put("u_cert_type", "");
                }

            } else {
                msgMap.put("u_cert_type", "");
            }
            if (null != nameIndex.get("PERSIONCERTIFICATEID")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONCERTIFICATEID")]) {
                    msgMap.put("u_cert_id", (String) dataArr[nameIndex.get("PERSIONCERTIFICATEID")]);
                } else {
                    msgMap.put("u_cert_id", "");
                }

            } else {
                msgMap.put("u_cert_id", "");
            }
            if (null != nameIndex.get("PERSIONPHONENUM")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONPHONENUM")]) {
                    msgMap.put("u_phone", (String) dataArr[nameIndex.get("PERSIONPHONENUM")]);
                } else {
                    msgMap.put("u_phone", "");
                }

            } else {
                msgMap.put("u_phone", "");
            }
            if (null != nameIndex.get("PERSIONPROVINCE")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONPROVINCE")]) {
                    msgMap.put("u_person_province", new String(Base64.decodeFast((String) dataArr[nameIndex.get("PERSIONPROVINCE")]), "utf-8"));
                } else {
                    msgMap.put("u_person_province", "");
                }

            } else {
                msgMap.put("u_person_province", "");
            }
            if (null != nameIndex.get("PERSIONCITY")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONCITY")]) {
                    msgMap.put("u_person_city", new String(Base64.decodeFast((String) dataArr[nameIndex.get("PERSIONCITY")]), "utf-8"));
                } else {
                    msgMap.put("u_person_city", "");
                }

            } else {
                msgMap.put("u_person_city", "");
            }
            if (null != nameIndex.get("PERSIONDISTRICT")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONDISTRICT")]) {
                    msgMap.put("u_person_county", new String(Base64.decodeFast((String) dataArr[nameIndex.get("PERSIONDISTRICT")]), "utf-8"));
                } else {
                    msgMap.put("u_person_county", "");
                }

            } else {
                msgMap.put("u_person_county", "");
            }
            if (null != nameIndex.get("PERSIONDETAILADDRESS")) {
                if (null != (String) dataArr[nameIndex.get("PERSIONDETAILADDRESS")]) {
                    msgMap.put("u_address", new String(Base64.decodeFast((String) dataArr[nameIndex.get("PERSIONDETAILADDRESS")]), "utf-8"));
                } else {
                    msgMap.put("u_address", "");
                }

            } else {
                msgMap.put("u_address", "");
            }
            if (null != nameIndex.get("CONTACTNAME")) {
                if (null != (String) dataArr[nameIndex.get("CONTACTNAME")]) {
                    msgMap.put("u_contact_name", new String(Base64.decodeFast((String) dataArr[nameIndex.get("CONTACTNAME")]), "utf-8"));
                } else {
                    msgMap.put("u_contact_name", "");
                }

            } else {
                msgMap.put("u_contact_name", "");
            }
            if (null != nameIndex.get("CONTACTPHONE")) {
                if (null != (String) dataArr[nameIndex.get("CONTACTPHONE")]) {
                    msgMap.put("u_contact_phone", (String) dataArr[nameIndex.get("CONTACTPHONE")]);
                } else {
                    msgMap.put("u_contact_phone", "");
                }

            } else {
                msgMap.put("u_contact_phone", "");
            }
            if (null != nameIndex.get("CONTACTIDCARD")) {
                if (null != (String) dataArr[nameIndex.get("CONTACTIDCARD")]) {
                    msgMap.put("u_contact_idcard", (String) dataArr[nameIndex.get("CONTACTIDCARD")]);
                } else {
                    msgMap.put("u_contact_idcard", "");
                }

            } else {
                msgMap.put("u_contact_idcard", "");
            }
            String publishTime = (String) dataArr[nameIndex.get("SNAPSHOTTIME")];//PUBLISHTIME
            try {
                if (null == publishTime || publishTime.trim().isEmpty()) {
                    msgMap.put("m_gather_time", -1);
                    msgMap.put("m_is_pt_generated", 0);
                } else {
                    msgMap.put("m_gather_time", TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_is_pt_generated", 1);
                    msgMap.put("m_publish_time", TimeFormat.dateToStamp(publishTime));
                }
            } catch (Exception e) {
                logger.error(e, e);
                msgMap.put("m_gather_time", -1);
                msgMap.put("m_is_pt_generated", 0);
                msgMap.put("m_publish_time", -1);
            }
            msgMap.put("m_insert_time", -1);
            if (null != publishTime && !publishTime.trim().isEmpty()) {
                try {
                    Map<String, Integer> ymdh = TimeFormat.getYMDH(TimeFormat.dateToStamp(publishTime));
                    msgMap.put("m_year", ymdh.get("year"));
                    msgMap.put("m_month", ymdh.get("month"));
                    msgMap.put("m_day", ymdh.get("day"));
                    msgMap.put("m_hour", ymdh.get("hour"));
                } catch (Exception e) {
                    logger.error("publishTime is: " + publishTime + e, e);
                    msgMap.put("m_year", -1);
                    msgMap.put("m_month", -1);
                    msgMap.put("m_day", -1);
                    msgMap.put("m_hour", -1);
                }
            }
            msgMap.put("msg_type", (String) dataArr[nameIndex.get("msg_type")]);
            msgMap.put("key", (String) dataArr[nameIndex.get("key")]);
            return msgMap;
        } catch (Exception ex) {
            logger.error(ex, ex);
            return null;
        }
    }
    
    
    /**
     * 将base64数组转为 普通数组
     *
     * @param baseUrl 带[]的base64数组
     * @return 普通数组
     */
    public static String[] baseUrlsToUrls(String baseUrl) {
        String[] urls = null;
        try {
            if (null == baseUrl) {
                return new String[0];
            }
            if (baseUrl.length() < 2) {
                return new String[0];
            }
            String[] baseUrls = baseUrl.substring(1, baseUrl.length() - 1).split(",");
            urls = new String[baseUrls.length];
            for (int i = 0; i < baseUrls.length; i++) {
                urls[i] = new String(Base64.decodeFast(baseUrls[i]), "utf-8");
            }
            return urls;
        } catch (Exception e) {
            logger.error(e, e);
        } finally {
            if (null == urls) {
                urls = new String[0];
            }
            return urls;
        }
    }

    /**
     *
     * @param urls 所有url
     * @param time 日期
     * @param type 文件类型
     * @param msg_type 数据类型
     * @param company_key 公司唯一标识
     * @return
     */
    public static String[] getFilePath(String[] urls, String time, String type, String msg_type, String company_key) {
        String market = "";
        if(msg_type.equals("1") || msg_type.equals("2")|| msg_type.equals("3")||msg_type.equals("4")||msg_type.equals("5")){
            market = GlobalParas.FILE_PATH;
        }else if(msg_type.equals("appstore.basicinfo") || msg_type.equals("appstore.appcategory")|| msg_type.equals("appstore.app")||msg_type.equals("appstore.appcomments")||msg_type.equals("appstore.appcompany")){
            market = GlobalParas.APP_FILE_PATH;
        }else{
            logger.error("unknown msg_type is " + msg_type );
        }
        String[] paths = new String[urls.length]; 
        switch (type) {
            case "jpg":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + company_key + File.separator + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".jpg";
//                    paths[i] = GlobalParas.FILE_PATH + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".jpg";
                }
                break;
            case "mp4":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + company_key + File.separator + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".mp4";
                }
                break;
            case "mp3":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + company_key + File.separator + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".mp3";
                }
                break;
            case "user":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + company_key + File.separator + TimeFormat.getTimeString(Long.valueOf(time)) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".jpg";
                }
                break;
            default:
                for (int i = 0; i < urls.length; i++) {
                    String suffix = urls[i].substring(urls[i].lastIndexOf(".") + 1, urls[i].length());
                    if (suffix.length() > 5) {
                        paths[i] = market + company_key + File.separator + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]);
                    } else {
                        paths[i] = market + company_key + File.separator + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + "." + suffix;
                    }

                }
                ;
        }
        return paths;
    }
    
    
     public static String[] getFilePathSpecial(String[] urls, String time, String type, String msg_type, String company_key) {
        String market = "";
        if(msg_type.equals("1") || msg_type.equals("2")|| msg_type.equals("3")||msg_type.equals("4")||msg_type.equals("5")){
            market = GlobalParas.FILE_PATH;
        }else if(msg_type.equals("appstore.basicinfo") || msg_type.equals("appstore.appcategory")|| msg_type.equals("appstore.app")||msg_type.equals("appstore.appcomments")||msg_type.equals("appstore.appcompany")){
            market = GlobalParas.APP_FILE_PATH;
        }else{
            logger.error("unknown msg_type is " + msg_type );
        }
        String[] paths = new String[urls.length]; 
        switch (type) {
            case "jpg":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + "pic"+ File.separator + haCodes(urls[i]) + File.separator +haCodes(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".jpg";
//                    paths[i] = GlobalParas.FILE_PATH + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".jpg";
                }
                break;
            case "mp4":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + company_key + File.separator + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".mp4";
                }
                break;
            case "mp3":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + company_key + File.separator + time.substring(0, 8) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".mp3";
                }
                break;
            case "user":
                for (int i = 0; i < urls.length; i++) {
                    paths[i] = market + company_key + File.separator + TimeFormat.getTimeString(Long.valueOf(time)) + File.separator + haCode(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + ".jpg";
                }
                break;
            default:
                for (int i = 0; i < urls.length; i++) {
                    String suffix = urls[i].substring(urls[i].lastIndexOf(".") + 1, urls[i].length());
                    if (suffix.length() > 5) {
                        paths[i] = market + "apk" + File.separator + haCodes(urls[i]) + File.separator + haCodes(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i])+ ".apk";
                    } else {
                        paths[i] = market + "apk"+ File.separator + haCodes(urls[i]) + File.separator + haCodes(urls[i]) + File.separator + GenerateMD5.string2MD5(urls[i]) + "." + suffix;
                    }

                }
                ;
        }
        return paths;
    }
    
    
    

    public static String haCode(String name) {
        String s = Math.abs(name.hashCode()) % 1000 + "";
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < (3 - s.length()); i++) {
            sb.append("0");
        }
        sb.append(s);
        return sb.toString();
    }
  
        public static String haCodes(String name) {
        String s = Math.abs(name.hashCode()) % 10000 + "";
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < (3 - s.length()); i++) {
            sb.append("0");
        }
        sb.append(s);
        return sb.toString();
    }
//        public static void main(String[] args) {
//            String[] picUrls={};
//            picUrls = baseUrlsToUrls((["aHR0cDovL2kxLmdvMnlkLmNvbS9pbWFnZS5waHA/dXJsPTBJR1hoZHBzREs="]);
//            
//        }
    
    
    

}
